import request from '@/utils/request'

const api_prefix = '/admin/system/sysUser'

export default {

  /**
   * 获取用户详情
   *
   * @returns {*}
   */
  getUerDetails() {
    return request(({
      url: `${api_prefix}/detail`,
      method: 'get'
    }))
  },

  /**
   *  创建用户
   * @param sysUserAddRequest
   * @returns {*}
   */
  addUser(sysUserAddRequest) {
    return request({
      url: `${api_prefix}/add`,
      method: 'post',
      data: sysUserAddRequest
    })
  },

  /**
   * 删除用户
   *
   * @param deleteRequest
   * @returns {*}
   */
  deleteUser(deleteRequest) {
    return request(({
      url: `${api_prefix}/delete`,
      method: 'post',
      data: deleteRequest
    }))
  },

  /**
   * 批量删除用户
   *
   * @param ids
   * @returns {*}
   */
  batchDeleteUser(idList) {
    return request(({
      url: `${api_prefix}/batchDelete`,
      method: 'post',
      data: idList
    }))
  },

  /**
   * 更新用户
   *
   * @param sysUserUpdateRequest
   * @returns {*}
   */
  updateUser(sysUserUpdateRequest) {
    return request(({
      url: `${api_prefix}/update`,
      method: 'post',
      data: sysUserUpdateRequest
    }))
  },

  /**
   * 根据 id 获取用户
   *
   * @param id
   * @returns {*}
   */
  getUserById(id) {
    return request(({
      url: `${api_prefix}/get`,
      method: 'get',
      params: { id }
    }))
  },

  /**
   * 获取用户列表
   *
   * @param sysUserQueryRequest
   * @returns {*}
   */
  listUser(sysUserQueryRequest) {
    return request(({
      url: `${api_prefix}/list`,
      method: 'get',
      param: sysUserQueryRequest
    }))
  },

  /**
   * 分页获取用户列表
   *
   * @param current
   * @param pageSize
   * @param sysUserQueryRequest
   * @returns {*}
   */
  listUserByPage(current, pageSize, sysUserQueryRequest) {
    return request(({
      url: `${api_prefix}/list/page`,
      method: 'get',
      params: { current, pageSize, ...sysUserQueryRequest }
    }))
  },

  /**
   * 更新用户状态
   *
   * @param updateStatusRequest
   * @returns {*}
   */
  updateStatus(updateStatusRequest) {
    console.log(updateStatusRequest)
    return request(({
      url: `${api_prefix}/update/status`,
      method: 'get',
      params: updateStatusRequest
    }))
  }

}
